package com.che.software.testato.domain.entity;

import java.io.Serializable;

import com.che.software.testato.domain.enumeration.VariantTypes;

/**
 * Class representing a variant.
 * 
 * @author Clement HELIOU (clement.heliou@che-software.com).
 * @copyright Che Software.
 * @license GNU General Public License.
 * @see Serializable
 * @since July, 2011.
 * 
 *        This file is part of Testato.
 * 
 *        Testato is free software: you can redistribute it and/or modify it
 *        under the terms of the GNU General Public License as published by the
 *        Free Software Foundation, either version 3 of the License, or (at your
 *        option) any later version.
 * 
 *        Testato is distributed in the hope that it will be useful, but WITHOUT
 *        ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 *        FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
 *        for more details.
 * 
 *        You should have received a copy of the GNU General Public License
 *        along with Testato. If not, see <http://www.gnu.org/licenses/>.
 * 
 *        Testato's logo is a creation of Arrioch
 *        (http://arrioch.deviantart.com/) and it's distributed under the terms
 *        of the Creative Commons License.
 */
public class Variant implements Serializable {

	/**
	 * Constants.
	 */
	private static final long serialVersionUID = -4063903541440974053L;

	/**
	 * Members.
	 */
	private int testCaseId, variantId;
	private String label, quantitativeCriterion;
	private VariantTypes variantType;

	/**
	 * Getter for the private field value label with escaped quotes.
	 * 
	 * @return the label field value with escaped quotes.
	 */
	public String getEscapedLabel() {
		return (null != label) ? label.replaceAll("'", "&apos;") : label;
	}

	/**
	 * Checks if the variant is a success or not.
	 * 
	 * @author Clement HELIOU (clement.heliou@che-software.com).
	 * @return true if the variant is a success, else false.
	 * @since July, 2011.
	 */
	public boolean isSuccess() {
		return variantType.equals(VariantTypes.SUCCESS);
	}

	/**
	 * Getter for the private field value testCaseId.
	 * 
	 * @return the testCaseId field value.
	 */
	public int getTestCaseId() {
		return testCaseId;
	}

	/**
	 * Setting a value to the testCaseId field.
	 * 
	 * @param testCaseId the value to set.
	 */
	public void setTestCaseId(int testCaseId) {
		this.testCaseId = testCaseId;
	}

	/**
	 * Getter for the private field value variantId.
	 * 
	 * @return the variantId field value.
	 */
	public int getVariantId() {
		return variantId;
	}

	/**
	 * Setting a value to the variantId field.
	 * 
	 * @param variantId the value to set.
	 */
	public void setVariantId(int variantId) {
		this.variantId = variantId;
	}

	/**
	 * Getter for the private field value label.
	 * 
	 * @return the label field value.
	 */
	public String getLabel() {
		return label;
	}

	/**
	 * Setting a value to the label field.
	 * 
	 * @param label the value to set.
	 */
	public void setLabel(String label) {
		this.label = label;
	}

	/**
	 * Getter for the private field value quantitativeCriterion.
	 * 
	 * @return the quantitativeCriterion field value.
	 */
	public String getQuantitativeCriterion() {
		return quantitativeCriterion;
	}

	/**
	 * Setting a value to the quantitativeCriterion field.
	 * 
	 * @param quantitativeCriterion the value to set.
	 */
	public void setQuantitativeCriterion(String quantitativeCriterion) {
		this.quantitativeCriterion = quantitativeCriterion;
	}

	/**
	 * Getter for the private field value variantType.
	 * 
	 * @return the variantType field value.
	 */
	public VariantTypes getVariantType() {
		return variantType;
	}

	/**
	 * Setting a value to the variantType field.
	 * 
	 * @param variantType the value to set.
	 */
	public void setVariantType(VariantTypes variantType) {
		this.variantType = variantType;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return label;
	}
}